//
//  PublishIssueBottomView.m
//  LookScore
//
//  Created by wws on 2018/1/18.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "PublishIssueBottomView.h"

@interface PublishIssueBottomView(){
    UILabel *_textNumberLable;//字体统计控件
}
@end


@implementation PublishIssueBottomView

-(instancetype)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
        [self addIssueSubviews];
    }
    return self;
}


/*加入话题评论选择工具视图*/
-(void)addIssueSubviews{
    
    //顶部灰色的底线
    UIView  *topLineView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.width, 1)];
    topLineView.backgroundColor=LSSubGrayColorf7;
    [self addSubview:topLineView];
    
    
    //话题选择图片底部视图
    NSArray *toolImageNameArray=@[@"emoji_smile_tool",@"gallery_tool",@"camera_tool"];
    NSInteger startMaxX=10,btnSpasePadding=15;
    NSInteger toolBtnWidth=40,btnMaxX=startMaxX;
    
    for (NSInteger j=0;j<toolImageNameArray.count;j++) {
      
        UIButton *toolButton=[[UIButton alloc]init];
        toolButton.frame=CGRectMake(btnMaxX, topLineView.maxY, toolBtnWidth, toolBtnWidth);
        toolButton.tag=j;
        [toolButton addTarget:self action:@selector(toolBuutonTapSender:) forControlEvents:UIControlEventTouchUpInside];
        [toolButton setImage:[UIImage imageNamed:toolImageNameArray[j]] forState:UIControlStateNormal];
        toolButton.imageView.contentMode = UIViewContentModeScaleAspectFill;
        [self addSubview:toolButton];
        btnMaxX=toolButton.maxX+btnSpasePadding;
    }
    
    //字数显示
    NSInteger numberLableWidth=80;
    UILabel *textNumberLable=[[UILabel alloc]initWithFrame:CGRectMake(LSScreenWidth-numberLableWidth-10, 1, numberLableWidth, self.height-1)];
    textNumberLable.font=LSFontSize12;
    textNumberLable.text=@"0/2000";
    _textNumberLable=textNumberLable;
    textNumberLable.textAlignment=NSTextAlignmentRight;
    textNumberLable.textColor=LSTitleGrayColor2;
    [self addSubview:textNumberLable];
    
    
    
}

/*工具按钮点击toolBuutonTapSender*/
-(void)toolBuutonTapSender:(UIButton *)sender{
    if (_toolTapBlock) {
        _toolTapBlock(sender.tag);
    }
}

/*字数统计*/
-(void)setWordsNumber:(NSInteger)wordsNumber{
    _wordsNumber=wordsNumber;
    
    _textNumberLable.text=[NSString stringWithFormat:@"%ld/%d",wordsNumber,KWordsMaxXNumber];
}

@end
